unit Obs2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, DBCtrls, DB, DBTables, DBClient,
  Grids, DBGrids;

type
  TFormObs2 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    RadioGroup1: TRadioGroup;
    RadioGroup2: TRadioGroup;
    RadioGroup3: TRadioGroup;
    RadioGroup4: TRadioGroup;
    RadioGroup5: TRadioGroup;
    RadioGroup6: TRadioGroup;
    RadioGroup8: TRadioGroup;
    RadioGroup9: TRadioGroup;
    RadioGroup10: TRadioGroup;
    RadioGroup11: TRadioGroup;
    RadioGroup12: TRadioGroup;
    RadioGroup13: TRadioGroup;
    RadioGroup14: TRadioGroup;
    RadioGroup15: TRadioGroup;
    RadioGroup7: TRadioGroup;
    RadioGroup16: TRadioGroup;
    RadioGroup17: TRadioGroup;
    RadioGroup18: TRadioGroup;
    RadioGroup19: TRadioGroup;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure RadioGroup2Click(Sender: TObject);
    procedure RadioGroup3Click(Sender: TObject);
    procedure RadioGroup4Click(Sender: TObject);
    procedure RadioGroup8Click(Sender: TObject);
    procedure RadioGroup9Click(Sender: TObject);
    procedure RadioGroup10Click(Sender: TObject);
    procedure RadioGroup11Click(Sender: TObject);
    procedure RadioGroup12Click(Sender: TObject);
    procedure RadioGroup13Click(Sender: TObject);
    procedure RadioGroup14Click(Sender: TObject);
    procedure RadioGroup15Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure RadioGroup5Click(Sender: TObject);
    procedure RadioGroup6Click(Sender: TObject);
    procedure RadioGroup7Click(Sender: TObject);
    procedure RadioGroup19Click(Sender: TObject);
    procedure RadioGroup17Click(Sender: TObject);
    procedure RadioGroup16Click(Sender: TObject);
    procedure RadioGroup18Click(Sender: TObject);

  private
    { Private declarations }
    procedure GravaObs;
    procedure AlteraObs;
  public
    { Public declarations }
    xObs:string;
  end;

var
  FormObs2: TFormObs2;

implementation

uses Pedido, Principal;

{$R *.dfm}

procedure TFormObs2.BitBtn1Click(Sender: TObject);
begin

    GravaObs;
    close;


end;

procedure TFormObs2.BitBtn2Click(Sender: TObject);
begin

    close;
end;

procedure TFormObs2.GravaObs;
var xObs :string;

begin
    xObs := '';
    if RadioGroup1.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup1.Items[RadioGroup1.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup2.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup2.Items[RadioGroup2.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup3.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup3.Items[RadioGroup3.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup4.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup4.Items[RadioGroup4.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup5.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup5.Items[RadioGroup5.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup6.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup6.Items[RadioGroup6.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup7.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup7.Items[RadioGroup7.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup8.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup8.Items[RadioGroup8.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup9.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup9.Items[RadioGroup9.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup10.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup10.Items[RadioGroup10.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup11.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup11.Items[RadioGroup11.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup12.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup12.Items[RadioGroup12.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup13.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup13.Items[RadioGroup13.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup14.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup14.Items[RadioGroup14.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup15.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup15.Items[RadioGroup15.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup16.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup16.Items[RadioGroup16.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup17.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup17.Items[RadioGroup17.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup18.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup18.Items[RadioGroup18.ItemIndex]+StringOfChar(' ',20),1,20);

    if RadioGroup19.ItemIndex <> -1 then
       xObs := xObs + copy(RadioGroup19.Items[RadioGroup19.ItemIndex]+StringOfChar(' ',20),1,20);

    FormPrincipal.xObs := xObs;

end;




procedure TFormObs2.RadioGroup1Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup1.Items.Count-1 do
begin
   TRadioButton(RadioGroup1.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup1.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup1.Controls[RadioGroup1.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup1.Controls[RadioGroup1.ItemIndex]).Font.Style := [fsBold];

end;

procedure TFormObs2.RadioGroup2Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup2.Items.Count-1 do
begin
   TRadioButton(RadioGroup2.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup2.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup2.Controls[RadioGroup2.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup2.Controls[RadioGroup2.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup3Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup3.Items.Count-1 do
begin
   TRadioButton(RadioGroup3.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup3.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup3.Controls[RadioGroup3.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup3.Controls[RadioGroup3.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup4Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup4.Items.Count-1 do
begin
   TRadioButton(RadioGroup4.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup4.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup4.Controls[RadioGroup4.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup4.Controls[RadioGroup4.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup8Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup8.Items.Count-1 do
begin
   TRadioButton(RadioGroup8.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup8.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup8.Controls[RadioGroup8.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup8.Controls[RadioGroup8.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup9Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup9.Items.Count-1 do
begin
   TRadioButton(RadioGroup9.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup9.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup9.Controls[RadioGroup9.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup9.Controls[RadioGroup9.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup10Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup10.Items.Count-1 do
begin
   TRadioButton(RadioGroup10.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup10.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup10.Controls[RadioGroup10.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup10.Controls[RadioGroup10.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup11Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup11.Items.Count-1 do
begin
   TRadioButton(RadioGroup11.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup11.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup11.Controls[RadioGroup11.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup11.Controls[RadioGroup11.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup12Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup12.Items.Count-1 do
begin
   TRadioButton(RadioGroup12.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup12.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup12.Controls[RadioGroup12.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup12.Controls[RadioGroup12.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup13Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup13.Items.Count-1 do
begin
   TRadioButton(RadioGroup13.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup13.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup13.Controls[RadioGroup13.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup13.Controls[RadioGroup13.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup14Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup14.Items.Count-1 do
begin
   TRadioButton(RadioGroup14.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup14.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup14.Controls[RadioGroup14.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup14.Controls[RadioGroup14.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup15Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup15.Items.Count-1 do
begin
   TRadioButton(RadioGroup15.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup15.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup15.Controls[RadioGroup15.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup15.Controls[RadioGroup15.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.FormShow(Sender: TObject);
begin

    if trim(xObs) <> '' then
       AlteraObs;

end;

procedure TFormObs2.AlteraObs;
var xObs,x: string;
       I: Integer;
    Temp: TComponent;
begin

    xObs := FormPedido.EditObs.Text;

    while xObs <> '' do
    begin
        x := copy(xObs,1,20);
        if (RadioGroup1.Items[0] = trimright(x) ) or (RadioGroup1.Items[1] = trimright(x)) then  RadioGroup1.ItemIndex := (pos('sem ',x));
        if (RadioGroup2.Items[0] = trimright(x) ) or (RadioGroup2.Items[1] = trimright(x)) then  RadioGroup2.ItemIndex := (pos('sem ',x));
        if (RadioGroup3.Items[0] = trimright(x) ) or (RadioGroup3.Items[1] = trimright(x)) then  RadioGroup3.ItemIndex := (pos('sem ',x));
        if (RadioGroup4.Items[0] = trimright(x) ) or (RadioGroup4.Items[1] = trimright(x)) then  RadioGroup4.ItemIndex := (pos('sem ',x));
        if (RadioGroup5.Items[0] = trimright(x) ) or (RadioGroup5.Items[1] = trimright(x)) then  RadioGroup5.ItemIndex := (pos('sem ',x));
        if (RadioGroup6.Items[0] = trimright(x) ) or (RadioGroup6.Items[1] = trimright(x)) then  RadioGroup6.ItemIndex := (pos('sem ',x));
        if (RadioGroup7.Items[0] = trimright(x) ) or (RadioGroup7.Items[1] = trimright(x)) then  RadioGroup7.ItemIndex := (pos('sem ',x));
        if (RadioGroup8.Items[0] = trimright(x) ) or (RadioGroup8.Items[1] = trimright(x)) then  RadioGroup8.ItemIndex := (pos('sem ',x));
        if (RadioGroup9.Items[0] = trimright(x) ) or (RadioGroup9.Items[1] = trimright(x)) then  RadioGroup9.ItemIndex := (pos('sem ',x));
        if (RadioGroup10.Items[0] = trimright(x) ) or (RadioGroup10.Items[1] = trimright(x)) then  RadioGroup10.ItemIndex := (pos('sem ',x));
        if (RadioGroup11.Items[0] = trimright(x) ) or (RadioGroup11.Items[1] = trimright(x)) then  RadioGroup11.ItemIndex := (pos('sem ',x));
        if (RadioGroup12.Items[0] = trimright(x) ) or (RadioGroup12.Items[1] = trimright(x)) then  RadioGroup12.ItemIndex := (pos('sem ',x));
        if (RadioGroup13.Items[0] = trimright(x) ) or (RadioGroup13.Items[1] = trimright(x)) then  RadioGroup13.ItemIndex := (pos('sem ',x));
        if (RadioGroup14.Items[0] = trimright(x) ) or (RadioGroup14.Items[1] = trimright(x)) then  RadioGroup14.ItemIndex := (pos('sem ',x));
        if (RadioGroup15.Items[0] = trimright(x) ) or (RadioGroup15.Items[1] = trimright(x)) then  RadioGroup15.ItemIndex := (pos('sem ',x));
        if (RadioGroup16.Items[0] = trimright(x) ) or (RadioGroup16.Items[1] = trimright(x)) then  RadioGroup16.ItemIndex := (pos('sem ',x));
        if (RadioGroup17.Items[0] = trimright(x) ) or (RadioGroup17.Items[1] = trimright(x)) then  RadioGroup17.ItemIndex := (pos('sem ',x));
        if (RadioGroup18.Items[0] = trimright(x) ) or (RadioGroup18.Items[1] = trimright(x)) then  RadioGroup18.ItemIndex := (pos('sem ',x));
        if (RadioGroup19.Items[0] = trimright(x) ) or (RadioGroup19.Items[1] = trimright(x)) then  RadioGroup19.ItemIndex := (pos('sem ',x));
        delete(xObs,1,20);




    end;



end;



procedure TFormObs2.RadioGroup5Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup5.Items.Count-1 do
begin
   TRadioButton(RadioGroup5.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup5.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup5.Controls[RadioGroup5.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup5.Controls[RadioGroup5.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup6Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup6.Items.Count-1 do
begin
   TRadioButton(RadioGroup6.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup6.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup6.Controls[RadioGroup6.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup6.Controls[RadioGroup6.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup7Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup7.Items.Count-1 do
begin
   TRadioButton(RadioGroup7.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup7.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup7.Controls[RadioGroup7.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup7.Controls[RadioGroup7.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup19Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup19.Items.Count-1 do
begin
   TRadioButton(RadioGroup19.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup19.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup19.Controls[RadioGroup19.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup19.Controls[RadioGroup19.ItemIndex]).Font.Style := [fsBold];

end;

procedure TFormObs2.RadioGroup17Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup17.Items.Count-1 do
begin
   TRadioButton(RadioGroup17.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup17.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup17.Controls[RadioGroup17.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup17.Controls[RadioGroup17.ItemIndex]).Font.Style := [fsBold];
end;

procedure TFormObs2.RadioGroup16Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup16.Items.Count-1 do
begin
   TRadioButton(RadioGroup16.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup16.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup16.Controls[RadioGroup16.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup16.Controls[RadioGroup16.ItemIndex]).Font.Style := [fsBold];

end;

procedure TFormObs2.RadioGroup18Click(Sender: TObject);
var
i : Integer;
begin
for i := 0 to RadioGroup18.Items.Count-1 do
begin
   TRadioButton(RadioGroup18.Controls[i]).Font.Color := clBlack;
   TRadioButton(RadioGroup18.Controls[i]).Font.Style := [];
end;
TRadioButton(RadioGroup18.Controls[RadioGroup18.ItemIndex]).Font.Color := clBlue;
TRadioButton(RadioGroup18.Controls[RadioGroup18.ItemIndex]).Font.Style := [fsBold];

end;

end.
